package com.qianqian.service.utils;

import com.qianqian.service.model.GameRule;

import java.util.HashMap;
import java.util.Map;

public class GameRuleTools {

    public static final Map<String, GameRule> zhuanPanGameRules = new HashMap<String, GameRule>(){
        {
            put("dan", new GameRule("dan","单",0.95,"1,3"));
            put("shuang", new GameRule("shuang","双",0.95,"2,4"));
            put("da", new GameRule("da","大",0.95,"3,4"));
            put("xiao", new GameRule("xiao","小",0.95,"1,2"));
            put("zhong", new GameRule("zhong","中",0.95,"2,3"));
            put("bian", new GameRule("bian","边",0.95,"1,4"));
            put("yi", new GameRule("yi","一",2.85,"1"));
            put("er", new GameRule("er","二",2.85,"2"));
            put("san", new GameRule("san","三",2.85,"3"));
            put("si", new GameRule("si","四",2.85,"4"));
        }
    };

    public static double getOdds(String ruleCode){
        return zhuanPanGameRules.get(ruleCode).getOdds();
    }

    public static boolean getZhuanPanXiaZhuResult(int result,String ruleCode){
        GameRule gameRule = zhuanPanGameRules.get(ruleCode);
        String[] conditions =  gameRule.getCondition().split(",");
        for(int i=0;i<conditions.length;i++){
            int condition = Integer.parseInt(conditions[i]);
            if(condition==result){
                return true;
            }
        }
        return false;
    }
}
